import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import autoprefixer from 'autoprefixer'
import pxtorem from 'postcss-pxtorem'
import { resolve } from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      'components': resolve(__dirname, 'src/components'),
      'assets': resolve(__dirname, 'src/assets'),
      'utils': resolve(__dirname, 'src/utils')
    }
  },
  css: {
    postcss: {
      plugins: [
        autoprefixer(),
        pxtorem({
          rootValue: 37.5, // 移动端设计稿通常为375px宽度
          propList: ['*'], // 所有属性都转换
          selectorBlackList: ['.norem'], // 不转换的选择器
          minPixelValue: 2 // 小于2px的不转换
        })
      ]
    }
  },
  server: {
    host: true,
    port: 3000
  }
})
